package com.diandian.backend.member.param;

import com.diandian.base.boot.starter.exception.DefaultException;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.diandian.backend.member.dto.DouyinLifeMemberInfoAddParamDTO;

import java.io.Serializable;
import java.util.Date;

public class DouyinLifeMemberInfoAddParam implements Serializable {

	private String openId;
	private String mobile;
	private String accountId;
	private Double points; // 缺省：0
	private String level; // 缺省：1
	private String status; // 缺省：0 有效
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date operationTime; // 缺省：当前时间
	private String operationUserId;
	private String operationUserName;

	public void check(){
		if(this.openId == null || "".equals(this.openId)){
			throw new DefaultException("openId不能为空");
		}
		if(this.mobile == null || "".equals(this.mobile)){
			throw new DefaultException("手机号不能为空");
		}
		if(this.accountId == null || "".equals(this.accountId)){
			throw new DefaultException("accountId不能为空");
		}
		if(this.points == null){
			this.points = 0D;
		}
		if(this.level == null || "".equals(this.level)){
			this.level = "1";
		}
		if(this.status == null || "".equals(this.status)){
			this.status = "0";
		}
		if(this.status == null || "".equals(this.status)){
			this.status = "0";
		}
		if(this.operationTime == null){
			this.operationTime = new Date();
		}
//		if(this.operationUserId == null || "".equals(this.operationUserId)){
//			throw new DefaultException("operationUserId不能为空");
//		}
//		if(this.operationUserName == null || "".equals(this.operationUserName)){
//			throw new DefaultException("operationUserName不能为空");
//		}
	}

	public DouyinLifeMemberInfoAddParamDTO toDTO(){
		DouyinLifeMemberInfoAddParamDTO dto = new DouyinLifeMemberInfoAddParamDTO();
		dto.setOpenId(this.openId);
		dto.setMobile(this.mobile);
		dto.setAccountId(this.accountId);
		dto.setPoints(this.points);
		dto.setLevel(this.level);
		dto.setStatus(this.status);
		dto.setCreateTime(this.operationTime);
		dto.setCreateUserId(this.operationUserId);
		dto.setCreateUserName(this.operationUserName);
		dto.setUpdateTime(this.operationTime);
		dto.setUpdateUserId(this.operationUserId);
		dto.setUpdateUserName(this.operationUserName);
		return dto;
	}

	public String getOpenId() {
		return openId;
	}
	public String setOpenId(String openId) {
		return this.openId = openId;
	}
	public String getMobile() {
		return mobile;
	}
	public String setMobile(String mobile) {
		return this.mobile = mobile;
	}
	public String getAccountId() {
		return accountId;
	}
	public String setAccountId(String accountId) {
		return this.accountId = accountId;
	}
	public Double getPoints() {
		return points;
	}
	public Double setPoints(Double points) {
		return this.points = points;
	}
	public String getLevel() {
		return level;
	}
	public String setLevel(String level) {
		return this.level = level;
	}
	public String getStatus() {
		return status;
	}
	public String setStatus(String status) {
		return this.status = status;
	}

	public Date getOperationTime() {
		return operationTime;
	}

	public void setOperationTime(Date operationTime) {
		this.operationTime = operationTime;
	}

	public String getOperationUserId() {
		return operationUserId;
	}

	public void setOperationUserId(String operationUserId) {
		this.operationUserId = operationUserId;
	}

	public String getOperationUserName() {
		return operationUserName;
	}

	public void setOperationUserName(String operationUserName) {
		this.operationUserName = operationUserName;
	}
}
